home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Assembly / Mac68k / MANUAL / MAN2.DOC < prev    next >
Encoding:
Text File  |  1985-08-11  |  12.8 KB  |  379 lines  |  [TEXT/Anon]

  1.  
  2. MAC.68K
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                             INTRODUCTION
  10.                             INTRODUCTION
  11.                             INTRODUCTION
  12.  
  13.  
  14.  
  15.  
  16.  
  17.       MAC.68K is a fast, full featured assembler that can produce
  18.  
  19.  
  20.   clickable applications for the Macintosh. It is compatible with
  21.  
  22.  
  23.   the CPM-68K assembler AS68.
  24.  
  25.  
  26.  
  27.       MAC.68K can easily be used for small assembly programs, but
  28.  
  29.  
  30.   it also has the features and speed neccessary to build and
  31.  
  32.  
  33.   maintain very large programs.  It contains a full set of pseudo
  34.  
  35.  
  36.   operations, list options, macro definition capabiltites, and the
  37.  
  38.  
  39.   complete 68000 instruction set.  Key features include:
  40.  
  41.  
  42.  
  43.  
  44.            Macro definition/expansion
  45.  
  46.  
  47.            Hierarchical expression evalution
  48.  
  49.  
  50.            Column error flags
  51.  
  52.  
  53.            Included text files
  54.  
  55.  
  56.            Fast loading macro/symbol and code libraries
  57.  
  58.  
  59.            Nested conditionals
  60.  
  61.  
  62.            Sorted symbol table with cross references
  63.  
  64.  
  65.            String and substring manipulation
  66.  
  67.  
  68.  
  69.  
  70.       This manual describes the use and rules of MAC.68K. It does
  71.  
  72.  
  73.   not attempt to teach the M68000 assembly language, how to write
  74.  
  75.  
  76.   and debug an application, or the use and concepts of the
  77.  
  78.  
  79.   Macintosh toolbox.
  80.  
  81.  
  82.  
  83.  
  84.       This manual was originally written for the CPM-68K version of
  85.  
  86.  
  87.   MAC.68K. It contains some references to CPM-68K concepts that
  88.  
  89.  
  90.   have not been fully implemented yet on the Macintosh version. One
  91.  
  92.  
  93.   particular area of an unimplemented concept is the drive number
  94.  
  95.  
  96.   specification. In CPM-68K individual floppies are not named (no
  97.  
  98.  
  99.   volume names). Individual disk drives are specified by placing a
  100.  
  101.  
  102.   one character drive name (e.g. A:) as a prefix to a file name.
  103.  
  104.  
  105.   CYCLAN eventually plans some technique of specifying volume names
  106.  
  107.  
  108.   as a prefix so we are leaving in the documentation references to
  109.  
  110.  
  111.   drive names even though they currently have no effect on a
  112.  
  113.  
  114.   Macintosh assembly.
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                               -1-                               MAC.68K
  134.  
  135.  
  136.  
  137.                                                                 MAC.68K
  138.  
  139.  
  140.  
  141.  
  142.  
  143. I.  Invoking the Assembler
  144. I.  Invoking the Assembler
  145. I.  Invoking the Assembler
  146.  
  147.  
  148.  
  149.  
  150.  
  151.       MAC.68K is called with the following command line.  Square
  152.  
  153.  
  154.   brakets [] enclose the optional parameters.  Parameters may be
  155.  
  156.  
  157.   entered in any order. Single letter dash options may be grouped
  158.  
  159.  
  160.   together.
  161.  
  162.  
  163.  
  164.  
  165.     MAC  [-F d:]  [-P]  [-O object filename]  [-L]  [-U]  [-K]  [-C]
  166.  
  167.  
  168.          source filename  [>listing filename]
  169.  
  170.  
  171.  
  172.  
  173.   Option                  Purpose
  174.   ______                  _______
  175.  
  176.  
  177.  
  178.   -F d:                  Specifies the drive on which to place
  179.  
  180.  
  181.                          temporary files. If not given, the current
  182.  
  183.  
  184.                          drive is used.
  185.  
  186.  
  187.  
  188.  
  189.   -P                     Enables generation of the program listing.
  190.  
  191.  
  192.                          The default list device is the console. The
  193.  
  194.  
  195.                          listing can be redirected to another device
  196.  
  197.  
  198.                          or file by using the >filename parameter.
  199.  
  200.  
  201.                          Error messages are always sent to the
  202.  
  203.  
  204.                          console and to the selected output device
  205.  
  206.  
  207.                          or file.
  208.  
  209.  
  210.  
  211.  
  212.   -O object filename     Directs the object file from its default
  213.  
  214.  
  215.                          destination/name (see pseudo op IDENT) to
  216.  
  217.  
  218.                          the specified file name.
  219.  
  220.  
  221.  
  222.  
  223.   source filename        The only required parameter for MAC.68K.
  224.  
  225.  
  226.                          This file contains the source lines to be
  227.  
  228.  
  229.                          assembled.
  230.  
  231.  
  232.  
  233.  
  234.   >listing filename      If selected, the program listing is directed
  235.  
  236.  
  237.                          to the specified file instead of the console.
  238.  
  239.  
  240.                          -P is automatically enabled when a >filename
  241.  
  242.  
  243.                          is used.
  244.  
  245.  
  246.  
  247.  
  248.   -L                     Force long word absolute memory references.
  249.  
  250.  
  251.  
  252.  
  253.   -U                     Treat all undefined symbols as global
  254.  
  255.  
  256.                          references. (Future use)
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267. MAC.68K                                   -2-
  268.  
  269.  
  270.  
  271. MAC.68K
  272.  
  273.  
  274.  
  275.  
  276.  
  277.       While printing, MAC.68K monitors the keyboard prior to each
  278.  
  279.  
  280.   page break.  An S or ctl/C key will stop the assembly and control
  281.  
  282.  
  283.   will return to CPM-68K.  If MAC.68K is pausing on screen full,
  284.  
  285.  
  286.   any key other than S or ctl/C will resume the assembly.
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295. II.  MAC.68K LANGUAGE
  296. II.  MAC.68K LANGUAGE
  297. II.  MAC.68K LANGUAGE
  298.  
  299.  
  300.  
  301.  
  302.  
  303.   II.1 Instruction Fields
  304.   II.1 Instruction Fields
  305.   II.1 Instruction Fields
  306.  
  307.  
  308.  
  309.  
  310.       Each MAC.68K instruction consists of 4 optional fields
  311.  
  312.  
  313.   separated by one or more blanks. Each instruction line is
  314.  
  315.  
  316.   terminated by a carriage return character. Any line feed
  317.  
  318.  
  319.   characters following a carriage return are ignored.
  320.  
  321.  
  322.  
  323.  
  324.   Location    Operation Code    Operand(s)    Comment
  325.  
  326.  
  327.  
  328.  
  329.       The location field must begin in column 1. If column 1 is
  330.  
  331.  
  332.   blank then there is no location field. Depending on the operation
  333.  
  334.  
  335.   field, the location field contains either a symbol or a name.  A
  336.  
  337.  
  338.   location symbol may optionally end with a :  .
  339.  
  340.  
  341.  
  342.       The operation field begins with the first non-blank character
  343.  
  344.  
  345.   after the location field. It may begin no sooner than column 2,
  346.  
  347.  
  348.   but must appear by column 32. The operation field contains either
  349.  
  350.  
  351.   an M68000 op code, a pseudo op code, or a macro name.
  352.  
  353.  
  354.  
  355.       The operand field begins with the first non-blank character
  356.  
  357.  
  358.   following the operation field. It may consist of one or more
  359.  
  360.  
  361.   subfields separated by commas, and it too must begin by column
  362.  
  363.  
  364.   32. Depending on the operation field, these subfields contain an
  365.  
  366.  
  367.   M68000 effective address, an expression, a name, or a macro
  368.  
  369.  
  370.   argument. Note that a blank embedded in a character data item or
  371.  
  372.  
  373.   enclosed in a parenthesized macro parameter does not terminate an
  374.  
  375.  
  376.   operand subfield.
  377.  
  378.  
  379.  
  380.       The comment field begins with the first non-blank character
  381.  
  382.  
  383.   following the operand field.
  384.  
  385.  
  386.  
  387.  
  388.   II.2 Continuation Lines
  389.   II.2 Continuation Lines
  390.   II.2 Continuation Lines
  391.  
  392.  
  393.  
  394.  
  395.       Each instruction line may contain up to 256 data characters.
  396.  
  397.  
  398.   An instruction line (of any length) may be continued by placing a
  399.  
  400.  
  401.   , (comma) in column 1 of the next instruction line. A maximum of
  402.  
  403.  
  404.   two continuation lines are allowed. The total character count in
  405.  
  406.  
  407.  
  408.  
  409.  
  410.                               -3-                               MAC.68K
  411.  
  412.  
  413.  
  414.                                                                 MAC.68K
  415.  
  416.  
  417.  
  418.  
  419.  
  420.   a continued instruction may not exceed 256 characters.
  421.  
  422.  
  423.  
  424.  
  425.   II.3 Comment Lines
  426.   II.3 Comment Lines
  427.   II.3 Comment Lines
  428.  
  429.  
  430.  
  431.  
  432.       A comment line contains an asterisk or a semicolon in column
  433.  
  434.  
  435.   1 or blanks in columns 1 thru 32.
  436.  
  437.  
  438.  
  439.  
  440.   II.4 Imbedded Tab Characters
  441.   II.4 Imbedded Tab Characters
  442.   II.4 Imbedded Tab Characters
  443.  
  444.  
  445.  
  446.  
  447.       MAC.68K honors 2 types of imbedded tab conventions. The ASCII
  448.  
  449.  
  450.   tab character HT ($09) is expanded by inserting blanks until
  451.  
  452.  
  453.   column 1 9 17 25 33 41 49 57 65 73 or 81 is reached. The Pascal
  454.  
  455.  
  456.   blank compression sequence of character DLE ($10) followed by
  457.  
  458.  
  459.   character $20+n (where n is the number of blanks) will be
  460.  
  461.  
  462.   expanded by inserting n blanks.
  463.  
  464.  
  465.  
  466.  
  467.   II.5 Symbols
  468.   II.5 Symbols
  469.   II.5 Symbols
  470.  
  471.  
  472.  
  473.  
  474.       A symbol is a string of 1 to 8 characters that identifies a
  475.  
  476.  
  477.   value and its associated attributes. A symbol character may be
  478.  
  479.  
  480.   A-Z, a-z, 0-9, or one of the following:
  481.  
  482.  
  483.       .  $  _  =  ~           period dollar underscore equal tilda
  484.  
  485.  
  486.   A symbol may not begin with a number or a $.
  487.  
  488.  
  489.  
  490.       Valid Symbol Examples          Invalid Symbol Examples
  491.  
  492.  
  493.  
  494.   B           A123                  3TAG   (starts with a number)
  495.  
  496.  
  497.   broom       A456.789              *tag   (contains an invalid character)
  498.  
  499.  
  500.   _Sam        TAG                   p12345678   (too long)
  501.  
  502.  
  503.   SAM_T       tag$                  $TAG   (starts with a $)
  504.  
  505.  
  506.  
  507.       A symbol used in the location field of a M68000 instruction
  508.  
  509.  
  510.   is defined to have the current value of the location counter.
  511.  
  512.  
  513.  
  514.       A symbol used in the location field of a pseudo instruction
  515.  
  516.  
  517.   is defined to have a value based on an expression from an operand
  518.  
  519.  
  520.   field of the instruction. Certain pseudo operation codes create a
  521.  
  522.  
  523.   redefinable symbol whose value may be changed by another pseudo
  524.  
  525.  
  526.   operation. Unless a symbol is redefinable, any attempt to define
  527.  
  528.  
  529.   it with another value will generate a *D* type (Duplicate symbol
  530.  
  531.  
  532.   definition) error.
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547. MAC.68K                                   -4-
  548.  
  549.  
  550.  
  551. MAC.68K
  552.  
  553.  
  554.  
  555.  
  556.  
  557.   II.6 Reserved Symbols
  558.   II.6 Reserved Symbols
  559.   II.6 Reserved Symbols
  560.  
  561.  
  562.  
  563.  
  564.       Register names are reserved symbol names for MAC.68K. These
  565.  
  566.  
  567.   are A0-A7, D0-D7, a0-a7, d0-d7, A0.L-A7.L, D0.L-D7.L, a0.l-a7.l,
  568.  
  569.  
  570.   d0.l-d7.l, CCR, ccr, SR, sr, SP, sp, SSP, ssp, USP, usp, P and p.
  571.  
  572.  
  573.   Note that all register names you may use any combination of upper
  574.  
  575.  
  576.   case and lower case alphas. (E.g., CCR and cCr are equivalent).
  577.  
  578.  
  579.       The following special symbols are used to reference assembler
  580.  
  581.  
  582.   values:
  583.  
  584.  
  585.  
  586.     * or *L      Current value of the location counter.
  587.  
  588.  
  589.     *O           Current value of the origin counter.
  590.  
  591.  
  592.     *P           Current bit position within the current byte.
  593.  
  594.  
  595.  
  596.  
  597.       Symbol names ..0000 thru ..FFFF are reserved for use as local
  598.  
  599.  
  600.   symbol names within macro expressions.
  601.  
  602.  
  603.  
  604.  
  605.  
  606.   II.7 Upper and Lower Case Characters Within Symbols
  607.   II.7 Upper and Lower Case Characters Within Symbols
  608.   II.7 Upper and Lower Case Characters Within Symbols
  609.  
  610.  
  611.  
  612.  
  613.       By default lower case alphas are treated as unique
  614.  
  615.  
  616.   characters.  In this mode, BROOM and Broom are two distinct
  617.  
  618.  
  619.   symbol names.
  620.  
  621.  
  622.  
  623.       By selecting option UPPER (see pseudo op OPTION), all lower
  624.  
  625.  
  626.   case alpha characters (a-z) are internally converted to upper
  627.  
  628.  
  629.   case prior to being processed. In this mode, BROOM Broom BRooM
  630.  
  631.  
  632.   all refer to the same symbol.
  633.  
  634.  
  635.  
  636.       Regardless of the case option selected, the output listing
  637.  
  638.  
  639.   always contains the original upper and lower case characters.
  640.  
  641.  
  642.  
  643.  
  644.   II.8 Names
  645.   II.8 Names
  646.   II.8 Names
  647.  
  648.  
  649.  
  650.  
  651.       A name is a string of 1 to 8 characters that is used to
  652.  
  653.  
  654.   identify:
  655.  
  656.  
  657.  
  658.           Program               IF sequence
  659.  
  660.  
  661.           Macro                 String
  662.  
  663.  
  664.           DEFER sequence        M68000 instruction
  665.  
  666.  
  667.           DUP sequence          pseudo Instruction
  668.  
  669.  
  670.  
  671.  
  672.       Valid characters for a name are A-Z, 0-9, and _ . $ =.  A
  673.  
  674.  
  675.   name may not begin with a number.  Program names are further
  676.  
  677.  
  678.   restricted by operating system file name conventions. For CPM-68K
  679.  
  680.  
  681.   this means = is not a valid character.
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.                               -5-                               MAC.68K
  691.  
  692.  
  693.  
  694.                                                                 MAC.68K
  695.  
  696.  
  697.  
  698.  
  699.  
  700.       While lower case alphas may be used in the source file, they
  701.  
  702.  
  703.   will be internally converted to upper case (A-Z) before being
  704.  
  705.  
  706.   used in a name. For example, a moveq in the operation field is
  707.  
  708.  
  709.   always treated as MOVEQ regardless of the case option selected.
  710.  
  711.  
  712.  
  713.  
  714.   II.9 Concatenation or Ghost Characters
  715.   II.9 Concatenation or Ghost Characters
  716.   II.9 Concatenation or Ghost Characters
  717.  
  718.  
  719.  
  720.  
  721.       The & (ampersand) character is used to join two adjacent
  722.  
  723.  
  724.   strings in a source line. MAC.68K removes all & characters after
  725.  
  726.  
  727.   macro parameter substitution but before actual instruction
  728.  
  729.  
  730.   processing.  The ampersand is often called a ghost character
  731.  
  732.  
  733.   because it does not appear in the final listing.
  734.  
  735.  
  736.  
  737.       Concatenation may be used in any source line. It is not
  738.  
  739.  
  740.   restricted to use within macro definitions.
  741.  
  742.  
  743.  
  744.           Example of Concatenation Used Within a Macro Call
  745.  
  746.  
  747.  
  748.      A Macro Definition                       Macro Call
  749.  
  750.  
  751.  
  752.      TEST  MACRO  XX,ADDR                     TEST  EQ,TAG2
  753.  
  754.  
  755.            B&XX   ADDR
  756.  
  757.  
  758.            ENDM                               Macro Expansion
  759.  
  760.  
  761.  
  762.                                               BEQ   TAG2
  763.  
  764.  
  765.  
  766.  
  767.   II.10 Strings and String Substitution
  768.   II.10 Strings and String Substitution
  769.   II.10 Strings and String Substitution
  770.  
  771.  
  772.  
  773.  
  774.       MAC.68K uses pairs of " characters to signal string
  775.  
  776.  
  777.   substitution within a source line. Each " character pair brackets
  778.  
  779.  
  780.   a previously defined string name. The entire reference ("s and
  781.  
  782.  
  783.   name) is removed and the actual string value is substituted.
  784.  
  785.  
  786.   After substitution the remaining characters in the source line
  787.  
  788.  
  789.   will be shifted left or right the appropriate number of
  790.  
  791.  
  792.   positions.
  793.  
  794.  
  795.       A null string name is valid.
  796.  
  797.  
  798.  
  799.                   Example of String Substitution
  800.  
  801.  
  802.  
  803.     Definition
  804.  
  805.  
  806.  
  807.       DATE  STRING  1,,* 1/12/84*
  808.  
  809.  
  810.  
  811.     Use
  812.  
  813.  
  814.  
  815.             DC.L  8H"DATE"      becomes --->     DC.L  8H 1/12/84
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827. MAC.68K                                   -6-
  828.  
  829.  
  830.    DC.L  8H"DA